<template>
  <div>
    <div class="class_mid">
    <van-nav-bar
      :title='bigClassDetail.comboname'
      left-text="返回"
      left-arrow
      @click-left="$router.go(-1)"
      style="width:100vw"
    />
    </div>
    <div v-if="dataisshow">
      <div class="feng_img two">
        <img :src="'http://upenglish.ayvvv.cn' + bigClassDetail.comboimage" alt="">
      </div>
      <div class="detail_xia">
        <van-list
        v-for="item in smallClass" :key="item.id"
        >
        <van-cell :title="item.classname" @click="getInsurance(item.id, item.entrytime, item.exittime)">
          <div slot="default" class="history">
            <div class="history-title">
              <span class="special">{{ item.isstudy ? '已学习' : '未学习' }}</span>
              <span>{{ item.isend ? '已过期' : '未过期' }}</span>
            </div>
            <div class="history-author">
              <span class="shang">{{ item.startime | dateFormat }}</span>
            </div>
          </div>
        </van-cell>
      </van-list>
            <!-- <div class="detail_text">
          <div>
            <span>已过期课程</span>
          </div>
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
import { outDataClass, jilvClass } from '@/api/class.js'
import { mapState } from 'vuex'
export default {
  data () {
    return {
      bigClassDetail: [],
      smallClass: [],
      show: true,
      dataisshow: false
    }
  },
  prop: {
  },
  created () {
    this.getOutDataClass()
  },
  computed: {
    ...mapState(['id'])
  },
  methods: {
    async getOutDataClass () {
      this.$toast.loading({
        message: '获取中...',
        forbidClick: true,
        duration: 0
      })
      const id = this.$route.params.id
      // console.log(id)
      const { data } = await outDataClass({
        comboid: id,
        userid: this.id
      })
      console.log(data)
      this.bigClassDetail = data.combo
      this.smallClass = data.class
      if (data) {
        this.dataisshow = true
        this.$toast.clear()
      }
    },
    async getInsurance (id, jin, chu) {
      const Qid = this.$route.params.id
      const { data } = await jilvClass({
        userid: this.id,
        comboid: Qid,
        classid: id,
        entrytime: jin,
        exittime: chu
      })
      console.log(data)
      // this.$dialog.alert({ message: data.msg }).then(() => {})
    }
  }
}
</script>

<style scoped lang='less'>
.feng_img {
  img {
    width: 750px;
    height: 500px;
  }
}
.detail_xia {
  width: 600px;
  margin: 0 auto;
  margin-top: 30px;
  .detail_title {
    padding-bottom: 20px;
  }
  .detail_text {
    padding-bottom: 20px;
  }
  .detail_btn {
    position: relative;
    padding-bottom: 20px;
    .van-button {
      width: 180px;
      height: 50px;
    }
  }
}
.time span {
  font-size: 14px;
}
.van-cell {
  box-shadow: 0px 0px 10px #ccc;
  margin-bottom: 30px;
}
.history {
  width: 100%;
  height: 100px;
  .history-title {
    padding: 15px;
    height: 40px;
    p {
      font-size: 30px;
      font-weight: 700;
    }
  }
  .history-author {
    position: relative;
    .shang {
      position: absolute;
      top: -10px;
      right: 10px;
      font-style: 12px;
    }
  }
}
.special {
    display: inline-block;
    margin-right: 15px;
}
</style>
